class TestObj:
    def __init__(self,name,age):
        self.name=name
        self.age=age

    def test(self):
        print("执行test方法")

    def study(self):
        print("{}努力学习".format(self.name))

    def sleep(self):
        print("{}在睡觉".format(self.name))

def play():
    print("对象不想学习，就想天天打游戏")


xiaoming = TestObj("小明", 18)
xiaoming.study()
setattr(xiaoming, "study", play)  # 修改对象的方法
xiaoming.study()

# setattr(xiaoming, "name", "小红")  # 修改属性值
#
# # delattr(xiaoming, "name")
# print(xiaoming.name)

# value = input("你想对象现在干什么：")
# getattr(xiaoming, value)()

# value = input("你想获取对象的：")
# if hasattr(xiaoming, value):
#     print(getattr(xiaoming, value))
# else:
#     print("对象内不存在{}属性".format(value))
# print(getattr(xiaoming, "name"))
# print(getattr(xiaoming, "age"))
# getattr(xiaoming, "test")()
# getattr(xiaoming, "xiaoming.test()")


class Test():

    def click_login_button(self):
        print("点击登录按钮。。。。")

    def click_close(self):
        print("点击关闭按钮。。。。")

    def send_login_name(self):
        print("输入用户名。。。。")

# page = Test()
# getattr(page, "search")()
# test_data = ["send_login_name", "click_login_button", "click_close"]
# for data in test_data:
#     getattr(page, data)()